//p1030
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

// - The first thing is how to save the tree.
// - No! I think we don't need building the tree!

void beford(string in, string after){
    if (in.size() > 0) {
        char ch = after[after.size() - 1];
        cout << ch;
        int k = in.find(ch);
        beford(in.substr(0, k), after.substr(0, k));
        beford(in.substr(k + 1), after.substr(k, in.size() - k - 1));
    }
}
int main(){
    string inord, aftord;
    cin >> inord; cin >> aftord;
    beford(inord, aftord); cout << endl;
    return 0;
}
